import { createVNode, render } from "vue";
import type { RouteRecordRaw } from "vue-router"; //引入vue-router类型
// 引入静态路由
import { staticRoutes } from "./static";
import { createRouter, createWebHashHistory } from "vue-router";
/**
 * createRouter函数 会返回一个router实例
 * 函数里面进行配置：history路由模式
 * */
const router = createRouter({
  history: createWebHashHistory(),
  routes: staticRoutes,
});

//路由前置守卫
router.beforeEach((to, from, next) => {
  //?判断元信息是否有授权 无授权后期还需要判断token
  if (to.meta.authorization) {
  }
  next();
});
//切换页面换title 全局的后置守卫
router.afterEach((to, next) => {
  (document.querySelector("title") as HTMLElement).innerText =
    to.meta.title + "";
});

// router完成后导出到maints挂载
export default router;
